package acwing.图.二分图;

import java.util.Arrays;
import java.util.Scanner;

/**
 * 染色法判定二分图
 *
 * @author yang
 * @date 2022/1/14
 */
public class 染色法判定二分图 {

    static int N = 100010;
    static int M = 200010;
    static int[] color = new int[N];
    static int[] e = new int[M];
    static int[] h = new int[M];
    static int[] ne = new int[M];
    static int idx, n , m;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        Arrays.fill(h, -1);
        while (m-- > 0) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            add(a, b);
            add(b, a);
        }
        boolean flag = true;
        for (int i = 1; i <= n; i++) {
            if(color[i] == 0) {
                if (!dfs(i, 1)) {
                    flag = false;
                    break;
                }
            }
        }
        if (flag) System.out.println("Yes");
        else System.out.println("No");
    }

    private static boolean dfs(int u, int c) {
        color[u] = c;
        for (int i = h[u]; i != -1; i = ne[i]) {
            int j = e[i];
            if (color[j] == 0) {
                if (!dfs(j,3 - c)) return false;
            }
            else if (color[j] == c) return false;
        }
        return true;
    }

    private static void add(int x, int y) {
        e[idx] = y;
        ne[idx] = h[x];
        h[x] = idx++;
    }
}
